package com.sweet.pay.dto;


import com.sweet.pay.enums.TradeType;
import com.sweet.pay.utils.DoubleUtils;
import org.springframework.util.StringUtils;

/**
 * Created by sweet on 2019/6/5.
 * ---------------------------
 */


public class WxPayParam {

  private String body; // 商品说明

  private String orderNo; // 订单号

  private Double totalFee; // 订单总金额

  private TradeType tradeType;

  private String productId; // 商品ID tradeType=NATIVE 必传

  public WxPayParam() {
  }

  public WxPayParam(String body, String orderNo, Double totalFee, String productId, TradeType tradeType) {
    this.body = body;
    this.orderNo = orderNo;
    this.totalFee = totalFee;
    this.tradeType = tradeType;
    if (TradeType.NATIVE == tradeType && StringUtils.isEmpty(productId)) {
      throw new RuntimeException("tradeType=NATIVE, productId必传");
    }
    this.productId = productId;
  }

  public String getProductId() {
    return productId;
  }

  public void setProductId(String productId) {
    this.productId = productId;
  }

  public TradeType getTradeType() {
    return tradeType;
  }

  public void setTradeType(TradeType tradeType) {
    this.tradeType = tradeType;
  }

  public String getTotalFee() {
    return "" + DoubleUtils.multiply(totalFee.toString(), "100");
  }

  public void setTotalFee(Double totalFee) {
    this.totalFee = totalFee;
  }

  public String getOrderNo() {
    return orderNo;
  }

  public void setOrderNo(String orderNo) {
    this.orderNo = orderNo;
  }

  public String getBody() {
    return body;
  }

  public void setBody(String body) {
    this.body = body;
  }
}
